﻿using Little.Soldier.SWIFT;
using Little.Soldier.SWIFT.Definition;
using System.Collections.Generic;
using System.ComponentModel;

namespace Little.Soldier.SWIFT.Messages.Category0
{
  public class MT056 : SwiftMessage
  {
    private static SwiftMessageDefinition MessageDefinition;
    private static SwiftTagDefinition U0002;
    private static SwiftTagSubItemDefinition U0003;
    private static SwiftTagDefinition U0004;
    private static SwiftTagSubItemDefinition U0005;
    private static SwiftTagDefinition U0006;
    private static SwiftTagSubItemDefinition U0007;
    private static SwiftTagDefinition U0008;
    private static SwiftTagSubItemDefinition U000E;
    private static SwiftTagSubItemDefinition U000F;
    private static SwiftTagSubItemDefinition U0010;
    private static SwiftTagSubItemDefinition U0011;

    [Description("Section Number")]
    public Tag202 SectionNumber_202
    {
      get
      {
        return new Tag202((SwiftElement) this, 0, (SwiftDefinitionElement) MT056.U0002);
      }
    }

    [Description("Section Number")]
    public Tag202 Tag202_SectionNumber
    {
      get
      {
        return this.SectionNumber_202;
      }
    }

    [Description("Total Sections")]
    public Tag203 TotalSections_203
    {
      get
      {
        return new Tag203((SwiftElement) this, 0, (SwiftDefinitionElement) MT056.U0004);
      }
    }

    [Description("Total Sections")]
    public Tag203 Tag203_TotalSections
    {
      get
      {
        return this.TotalSections_203;
      }
    }

    [Description("9th character of BIC-12.")]
    public Tag305 LTCode_305
    {
      get
      {
        return new Tag305((SwiftElement) this, 0, (SwiftDefinitionElement) MT056.U0006);
      }
    }

    [Description("9th character of BIC-12.")]
    public Tag305 Tag305_LTCode
    {
      get
      {
        return this.LTCode_305;
      }
    }

    [Description("Login Attempt")]
    public Tag270[] LoginAttempt_270
    {
      get
      {
        int index = -1;
        List<Tag270> list = new List<Tag270>();
        int count;
        do
        {
          ++index;
          Tag270 tag270 = new Tag270((SwiftElement) this, index, (SwiftDefinitionElement) MT056.U0008);
          count = this.ListTags((SwiftElement) tag270).Count;
          if (count > 0)
            list.Add(tag270);
        }
        while (count > 0);
        return list.ToArray();
      }
    }

    [Description("Login Attempt")]
    public Tag270[] Tag270_LoginAttempt
    {
      get
      {
        return this.LoginAttempt_270;
      }
    }

    public MT056()
      : base(true)
    {
    }

    public MT056(SwiftMessage message)
      : base(message)
    {
    }

    public Tag270 AddLoginAttempt_270()
    {
      return new Tag270((SwiftElement) this, this.LoginAttempt_270.Length, (SwiftDefinitionElement) MT056.U0008)
      {
        Value = string.Empty
      };
    }

    public void RemoveLoginAttempt_270(Tag270 tag)
    {
      this.RemoveTag(tag.GetTag());
    }

    internal override SwiftMessageDefinition MsgDefinition()
    {
      return MT056.MessageDefinition;
    }

    protected override void InitSwiftMessageDefinition()
    {
      MT056.MessageDefinition = new SwiftMessageDefinition("MT056", "LT History Report");
      MT056.U0002 = new SwiftTagDefinition("SectionNumber_202", "Section Number");
      MT056.U0002.TagName = "{202:";
      MT056.U0003 = new SwiftTagSubItemDefinition("SectionNumber", "Sequential Section Number");
      MT056.U0002.Elements.Add((SwiftDefinitionElement) MT056.U0003);
      MT056.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT056.U0002);
      MT056.U0004 = new SwiftTagDefinition("TotalSections_203", "Total Sections");
      MT056.U0004.TagName = "{203:";
      MT056.U0005 = new SwiftTagSubItemDefinition("TotalSections", "Total number of sections in a multi-section message.");
      MT056.U0004.Elements.Add((SwiftDefinitionElement) MT056.U0005);
      MT056.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT056.U0004);
      MT056.U0006 = new SwiftTagDefinition("LTCode_305", "9th character of BIC-12.");
      MT056.U0006.TagName = "{305:";
      MT056.U0007 = new SwiftTagSubItemDefinition("LTCode", "9th character of BIC-12.");
      MT056.U0006.Elements.Add((SwiftDefinitionElement) MT056.U0007);
      MT056.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT056.U0006);
      MT056.U0008 = new SwiftTagDefinition("LoginAttempt_270", "Login Attempt");
      MT056.U0008.TagName = "{270:";
      MT056.U0008.Multiple = true;
      MT056.U000E = new SwiftTagSubItemDefinition("TimeStamp", "");
      MT056.U000F = new SwiftTagSubItemDefinition("TimeStamp_1", "");
      MT056.U000E.Elements.Add((SwiftDefinitionElement) MT056.U000F);
      MT056.U0008.Elements.Add((SwiftDefinitionElement) MT056.U000E);
      MT056.U0010 = new SwiftTagSubItemDefinition("SWIFT_CATEGORYS_MTS02_Interchange", "");
      MT056.U0008.Elements.Add((SwiftDefinitionElement) MT056.U0010);
      MT056.U0011 = new SwiftTagSubItemDefinition("SWIFT_CATEGORYS_MTS22_MTS42", "");
      MT056.U0011.Mandatory = false;
      MT056.U0008.Elements.Add((SwiftDefinitionElement) MT056.U0011);
      MT056.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT056.U0008);
    }
  }
}
